<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
#use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (Schema::hasTable('agreements')) return;
        Schema::create('agreements', function (Blueprint $table) {
            $table->id();
            $table->tinyInteger('type')->default(1)->comment('协议类型');
            $table->string('title')->default('')->comment('协议标题');
            $table->mediumText('content')->comment('协议内容');
            $table->boolean('is_enable')->default(1)->comment('是否启用：1是 0否');
            $table->boolean('is_delete')->default(0)->comment('是否删除：1是 0否');
            $table->dateTime('created_at')->default(\DB::raw('CURRENT_TIMESTAMP'));
            $table->timestamp('updated_at')->default(\DB::raw('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'));
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        if (!is_production()) Schema::dropIfExists('agreements');
    }
};
